package com.uhu.code.help;

import cn.hutool.core.util.ObjectUtil;

import java.util.Arrays;
import java.util.List;

public class HelpUtils {
    /**
     * 输出类
     *
     * @param obj
     */
    public static void outObj(Object obj) {
        if (obj instanceof int[]) {
            System.out.println(Arrays.toString((int[]) obj));
        } else if (obj instanceof List) {
            System.out.println(obj.toString());
        } else if (obj instanceof String[]) {
            System.out.println(Arrays.toString((String[]) obj));
        } else if (obj instanceof int[][]) {
            System.out.println(Arrays.deepToString((int[][]) obj));
        } else if (obj instanceof long[]) {
            System.out.println(Arrays.toString((long[]) obj));
        } else {
            System.out.println(ObjectUtil.toString(obj));
        }
    }

    /**
     * 初始化链表
     * @param node
     * @return
     */
    public static ListNode initListNode(int [] node) {
        ListNode firstNode = new ListNode(node[0]);
        for (int i = 1; i < node.length; i++) {
            firstNode.addNode(node[i]);
        }
        return firstNode;
    }
}
